package dao.impl;

import dao.NewsDao;
import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;
import pojo.entity.News;
import util.MyBatisUtil;

public class NewsDaoImpl implements NewsDao {
    private static final Logger log=Logger.getLogger(NewsDaoImpl.class);
    SqlSession sqlSession=null;
    /**
     * 保存新闻信息的方法
     *
     * @param news
     * @return
     */
    @Override
    public int save(News news) {
        log.debug("保存新闻信息到数据库");
        System.out.println("数据===="+news.getNcontent()+"/"+news.getNtitle());
        sqlSession= MyBatisUtil.createSqlSession();
        int num=sqlSession.getMapper(NewsDao.class).save(news);
        MyBatisUtil.closeSqlSession(sqlSession);
        return num;
    }

}
